package com.example.day4_fragment;


import android.content.Context;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;


/**
 *
 */
public class StaticFragment extends Fragment  {



    private static final String TAG = "ytx-fragment";

    //重写构造
    public StaticFragment() {

    }

    @Override
    public void onAttach(Context context) {
        super.onAttach(context);
        Log.d(TAG, "onAttach: 和activity挂载");
    }

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Log.d(TAG, "onCreate: 创建");
    }

    //重写onCreateView方法：主要用于加载fragment布局
    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_static, container, false);
        Log.d(TAG, "onCreateView: 创建布局");
        return view;
    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        Log.d(TAG, "onActivityCreated: activy创建");
    }

    @Override
    public void onStart() {
        super.onStart();
        Log.d(TAG, "onStart: 启动");
    }

    @Override
    public void onResume() {
        super.onResume();
        Log.d(TAG, "onResume: 获得焦点");
    }

    @Override
    public void onPause() {
        super.onPause();
        Log.d(TAG, "onPause: 暂停");
    }

    @Override
    public void onStop() {
        super.onStop();
        Log.d(TAG, "onStop: 停止");
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        Log.d(TAG, "onDestroyView: 销毁布局");
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        Log.d(TAG, "onDestroy: 销毁");
    }

    @Override
    public void onDetach() {
        super.onDetach();
        Log.d(TAG, "onDetach: 取消挂载");
    }
}
